package icegps.com.pingdj.bean;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;

import icegps.com.pingdj.App;
import icegps.com.pingdj.R;
import icegps.com.pingdj.constant.Token;
import icegps.com.pingdj.utils.UnitUtils;
import timber.log.Timber;

import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Transient;

/**
 * Created by 111 on 2018/3/21.
 */
@Entity
public class DeviceStatus {
    @Id
    public Long id;
    private static DeviceStatus deviceStatus;
    private String ConnectionStatus;//连接状态
    private String deviceMode; //设备型号
    private String deviceImei; //设备串号
    private String softwareVersion; //软件版本
    private String cardMode; //板卡型号
    private String numberMode;//数传型号
    private String activateInfo;//激活信息

    private int maxRadio;//最大频道
    private int minRadio;//最小频道
    private int currentRadio;//当前频道

    private int controlOne;//控制通道1
    private int controlTwo;//控制通道2
    private int manualOrAuto;//手动自动
    private int insMode;//装机模式
    private String workAccuracy;//平地精度
    private double balanceDifference;//平衡差值

    private int area;
    private int height;
    private int length;
    private int speed;
    private int volume;
    private float workWidth;
    private double setValue;
    private float antennaLocation;//天线位置

    @Transient
    private int workAction; //作业状态
    @Transient
    private int workMode; //工作模式 / 手动/自动/自动下手动
    @Transient
    private double tragetHeight1; //目标高度
    @Transient
    private double currentTimedifference1;//实时高差
    @Transient
    private double tragetHeight2; //目标高度
    @Transient
    private double currentTimedifference2;//实时高差


    @Generated(hash = 12097749)
    public DeviceStatus(Long id, String ConnectionStatus, String deviceMode,
                        String deviceImei, String softwareVersion, String cardMode,
                        String numberMode, String activateInfo, int maxRadio, int minRadio,
                        int currentRadio, int controlOne, int controlTwo, int manualOrAuto,
                        int insMode, String workAccuracy, double balanceDifference, int area,
                        int height, int length, int speed, int volume, float workWidth,
                        double setValue, float antennaLocation) {
        this.id = id;
        this.ConnectionStatus = ConnectionStatus;
        this.deviceMode = deviceMode;
        this.deviceImei = deviceImei;
        this.softwareVersion = softwareVersion;
        this.cardMode = cardMode;
        this.numberMode = numberMode;
        this.activateInfo = activateInfo;
        this.maxRadio = maxRadio;
        this.minRadio = minRadio;
        this.currentRadio = currentRadio;
        this.controlOne = controlOne;
        this.controlTwo = controlTwo;
        this.manualOrAuto = manualOrAuto;
        this.insMode = insMode;
        this.workAccuracy = workAccuracy;
        this.balanceDifference = balanceDifference;
        this.area = area;
        this.height = height;
        this.length = length;
        this.speed = speed;
        this.volume = volume;
        this.workWidth = workWidth;
        this.setValue = setValue;
        this.antennaLocation = antennaLocation;
    }

    @Generated(hash = 1820306817)
    public DeviceStatus() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getConnectionStatus() {
        return this.ConnectionStatus;
    }

    public void setConnectionStatus(String ConnectionStatus) {
        this.ConnectionStatus = ConnectionStatus;
    }

    public String getDeviceMode() {
        return this.deviceMode;
    }

    public void setDeviceMode(String deviceMode) {
        this.deviceMode = deviceMode;
    }

    public String getDeviceImei() {
        return this.deviceImei;
    }

    public void setDeviceImei(String deviceImei) {
        this.deviceImei = deviceImei;
    }

    public String getSoftwareVersion() {
        return this.softwareVersion;
    }

    public void setSoftwareVersion(String softwareVersion) {
        this.softwareVersion = softwareVersion;
    }

    public String getCardMode() {
        return this.cardMode;
    }

    public void setCardMode(String cardMode) {
        this.cardMode = cardMode;
    }

    public String getNumberMode() {
        return this.numberMode;
    }

    public void setNumberMode(String numberMode) {
        this.numberMode = numberMode;
    }

    public String getActivateInfo() {
        return this.activateInfo;
    }

    public void setActivateInfo(String activateInfo) {
        this.activateInfo = activateInfo;
    }

    public int getMaxRadio() {
        return this.maxRadio;
    }

    public void setMaxRadio(int maxRadio) {
        this.maxRadio = maxRadio;
    }

    public int getMinRadio() {
        return this.minRadio;
    }

    public void setMinRadio(int minRadio) {
        this.minRadio = minRadio;
    }

    public int getCurrentRadio() {
        return this.currentRadio;
    }

    public void setCurrentRadio(int currentRadio) {
        this.currentRadio = currentRadio;
    }

    public int getControlOne() {
        return this.controlOne;
    }

    public void setControlOne(int controlOne) {
        this.controlOne = controlOne;
    }

    public int getControlTwo() {
        return this.controlTwo;
    }

    public void setControlTwo(int controlTwo) {
        this.controlTwo = controlTwo;
    }

    public int getManualOrAuto() {
        return this.manualOrAuto;
    }

    public void setManualOrAuto(int manualOrAuto) {
        this.manualOrAuto = manualOrAuto;
    }

    public int getInsMode() {
        return this.insMode;
    }

    public void setInsMode(int insMode) {
        this.insMode = insMode;
    }

    public String getWorkAccuracy() {
        return this.workAccuracy;
    }

    public void setWorkAccuracy(String workAccuracy) {
        this.workAccuracy = workAccuracy;
    }

    public double getBalanceDifference() {
        return this.balanceDifference;
    }

    public void setBalanceDifference(double balanceDifference) {
        this.balanceDifference = balanceDifference;
    }

    public int getArea() {
        return this.area;
    }

    public void setArea(int area) {
        this.area = area;
    }

    public int getHeight() {
        return this.height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getLength() {
        return this.length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getSpeed() {
        return this.speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public int getVolume() {
        return this.volume;
    }

    public void setVolume(int volume) {
        this.volume = volume;
    }

    public float getWorkWidth() {
        return this.workWidth;
    }

    public void setWorkWidth(float workWidth) {
        this.workWidth = workWidth;
    }

    public double getSetValue() {
        return this.setValue;
    }

    public void setSetValue(double setValue) {
        this.setValue = setValue;
    }

    public float getAntennaLocation() {
        return this.antennaLocation;
    }

    public void setAntennaLocation(float antennaLocation) {
        this.antennaLocation = antennaLocation;
    }


    public int getWorkAction() {
        return workAction;
    }

    public void setWorkAction(int workAction) {
        this.workAction = workAction;
    }

    public int getWorkMode() {
        return workMode;
    }

    public void setWorkMode(int workMode) {
        this.workMode = workMode;
    }

    public double getTragetHeight1() {
        return tragetHeight1;
    }

    public void setTragetHeight1(double tragetHeight1) {
        this.tragetHeight1 = tragetHeight1;
    }

    public double getCurrentTimedifference1() {
        return currentTimedifference1;
    }

    public void setCurrentTimedifference1(double currentTimedifference1) {
        this.currentTimedifference1 = currentTimedifference1;
    }

    public double getTragetHeight2() {
        return tragetHeight2;
    }

    public void setTragetHeight2(double tragetHeight2) {
        this.tragetHeight2 = tragetHeight2;
    }

    public double getCurrentTimedifference2() {
        return currentTimedifference2;
    }

    public void setCurrentTimedifference2(double currentTimedifference2) {
        this.currentTimedifference2 = currentTimedifference2;
    }

    public static void init() {
        if (deviceStatus == null) {
            synchronized (DeviceStatus.class) {
                if (deviceStatus == null) {
                    deviceStatus = App.getInstance().getDaoSession().getDeviceStatusDao().load(Token.DEVICE_STATUS_TOKEN);
                    if (deviceStatus == null) {
                        Timber.e(DeviceStatus.class.getName().hashCode() + "");
                        deviceStatus = new DeviceStatus();
                        initConfig();
                        App.getInstance().getDaoSession().getDeviceStatusDao().insertOrReplace(deviceStatus);
                    }
                }
            }
        }
    }

    public static DeviceStatus getDeviceStatus() {
        return deviceStatus;
    }

    public static void initConfig() {
        deviceStatus.setId(Token.DEVICE_STATUS_TOKEN);
        deviceStatus.setArea(UnitUtils.value2Index(UnitUtils.AREA, App.getInstance().getString(R.string.mu)));
        deviceStatus.setHeight(UnitUtils.value2Index(UnitUtils.HEIGHT, App.getInstance().getString(R.string.meter)));
        deviceStatus.setLength(UnitUtils.value2Index(UnitUtils.LENGTH, App.getInstance().getString(R.string.meter)));
        deviceStatus.setSpeed(UnitUtils.value2Index(UnitUtils.SPEED, App.getInstance().getString(R.string.km_hr)));
        deviceStatus.setVolume(UnitUtils.value2Index(UnitUtils.VOLUME, App.getInstance().getString(R.string.stere)));
        deviceStatus.setWorkAccuracy(1.0f + "");
        deviceStatus.setWorkWidth(3.0f);
        deviceStatus.setSetValue(0);
        deviceStatus.setCurrentRadio(2);
    }


}
